package com.yuwei.home.parking_space_management.car_adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.yuwei.home.databinding.HomeMenuItemBinding
import com.yuwei.home.parking_space_management.entity.ServiceEntity

class HotServiceAdapter(private val data:MutableList<ServiceEntity>):RecyclerView.Adapter<HotServiceAdapter.HotItemViewHolder>(){
    inner class HotItemViewHolder(val itemDataBinding:HomeMenuItemBinding):RecyclerView.ViewHolder(itemDataBinding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HotItemViewHolder {
        val itemDataBinding = HomeMenuItemBinding.inflate(LayoutInflater.from(parent.context),parent,false)
        return HotItemViewHolder(itemDataBinding)
    }

    override fun getItemCount(): Int = data.size

    override fun onBindViewHolder(holder: HotItemViewHolder, position: Int) {
        val entity = data[position]
        holder.itemDataBinding.entity = entity
        //执行绑定操作
        holder.itemDataBinding.executePendingBindings()
    }
}